import java.io.*;

/*
ID: huangmingbo
LANG: JAVA
TASK: beads
*/
public class beads {


    public static void main(String[] args) throws IOException {
        try (
                InputStreamReader inputStreamReader = new InputStreamReader(beads.class.getResourceAsStream(beads.class.getSimpleName() + ".in"));
                BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                PrintWriter printWriter = new PrintWriter(new FileWriter(beads.class.getSimpleName() + ".out"));
        ) {
            deal(bufferedReader, printWriter);
        }
    }

    private static void deal(BufferedReader reader, PrintWriter writer) throws IOException {

        // get char num
        int charNum = Integer.parseInt(reader.readLine());

        // get char list
        char[] list = reader.readLine().toCharArray();

        // loop break point from 0 - list.length -1
        int maxlen = 0;
        int leftlen;
        int rightlen;
        for (int i = 0; i < charNum; i++) {
            leftlen = calculate(list, i - 1, -1);
            rightlen = calculate(list, i, 1);
            if (maxlen < leftlen + rightlen) {
                maxlen = leftlen + rightlen;
            }
        }

        maxlen = maxlen > charNum ? charNum : maxlen;

        writer.println(maxlen);

    }

    /**
     * @param charList
     * @param startIndex
     * @param direction  -1 = left , 1 = right
     * @return
     */
    private static int calculate(char[] charList, int startIndex, int direction) {

        int step = 1;
        int index = getValidIndex(startIndex, charList.length);
        char startChar = charList[index];
        char nextChar;
        while (step < charList.length) {
            nextChar = charList[getValidIndex(index = index + direction, charList.length)];
            if (nextChar == startChar || nextChar == 'w') {
                step++;
                continue;
            } else if (startChar == 'w') {
                startChar = nextChar;
                step ++;
                continue;
            }

            return step;
        }

        return step;
    }

    private static int getValidIndex(int index, int len) {
        if (index < 0) {
            return index + len;
        }

        if (index >= len) {
            return index - len;
        }

        return index;
    }
}
